#include "resource_manager.h"
#include <QAudioDeviceInfo>
#include <QDebug>

QList<ClothesInfo> ResourceManager::loadClothes() {
    QList<ClothesInfo> clothes;

    // 添加上衣
    clothes.append({
        "白色T恤",
        ":/upclothes/materialPackage/upclothes/T-shirt1.png",
        "上衣",
        QPoint(0, -30),
        QPoint(0, -50)
    });
    clothes.append({
        "蓝色T恤",
        ":/upclothes/materialPackage/upclothes/T-shirt2.png",
        "上衣",
        QPoint(0, -30),
        QPoint(0, -50)
    });
    clothes.append({
        "粉色T恤",
        ":/upclothes/materialPackage/upclothes/T-shirt3.png",
        "上衣",
        QPoint(0, -30),
        QPoint(0, -50)
    });
    clothes.append({
        "黄色T恤",
        ":/upclothes/materialPackage/upclothes/T-shirt4.png",
        "上衣",
        QPoint(0, -30),
        QPoint(0, -50)
    });
    clothes.append({
        "牛仔外套",
        ":/upclothes/materialPackage/upclothes/jacket.png",
        "上衣",
        QPoint(0, -30),
        QPoint(0, -60)
    });

    // 添加下装
    clothes.append({
        "运动裤",
        ":/downclothes/materialPackage/downclothes/trousers1.png",
        "下装",
        QPoint(0, 120),
        QPoint(0, 80)
    });
    clothes.append({
        "牛仔裤",
        ":/downclothes/materialPackage/downclothes/trousers2.png",
        "下装",
        QPoint(0, 120),
        QPoint(0, 80)
    });

    // 添加连衣裙
    clothes.append({
        "粉色连衣裙",
        ":/dress/materialPackage/dress/dress1.png",
        "连衣裙",
        QPoint(0, 50),
        QPoint(0, 20)
    });
    clothes.append({
        "蓝色连衣裙",
        ":/dress/materialPackage/dress/dress2.png",
        "连衣裙",
        QPoint(0, 50),
        QPoint(0, 20)
    });
    clothes.append({
        "中式连衣裙",
        ":/dress/materialPackage/dress/dress3.png",
        "连衣裙",
        QPoint(0, 50),
        QPoint(0, 20)
    });

    // 添加鞋子
    clothes.append({
        "凉鞋",
        ":/shoes/materialPackage/shoes/shoes1.png",
        "鞋子",
        QPoint(0, 300),
        QPoint(0, 220)
    });
    clothes.append({
        "皮鞋",
        ":/shoes/materialPackage/shoes/shoes2.png",
        "鞋子",
        QPoint(0, 300),
        QPoint(0, 220)
    });
    clothes.append({
        "运动鞋",
        ":/shoes/materialPackage/shoes/shoes3.png",
        "鞋子",
        QPoint(0, 300),
        QPoint(0, 220)
    });

    return clothes;
}

QList<OutfitCombo> ResourceManager::loadOutfitCombos()
{
    QList<OutfitCombo> combos;
    combos.append({
        "休闲套装",
        "白色T恤","","牛仔裤", "凉鞋",
        ":/combined/materialPackage/combined/T1_t2_s1.png"
    });
    combos.append({
        "休闲套装2",
        "白色T恤","","运动裤", "凉鞋",
        ":/combined/materialPackage/combined/T1_t1_s1.png"
    });
    combos.append({
        "休闲套装3",
        "白色T恤","","牛仔裤", "皮鞋",
        ":/combined/materialPackage/combined/T1_t2_s2.png"
    });
    // 如果需要连衣裙套装，可以这样定义
    combos.append({
        "连衣裙套装",
        "",           // top: 为空
        "粉色连衣裙",  // dress: 连衣裙名称
        "",           // bottom: 为空
        "凉鞋",       // shoes: 鞋子名称
        ":/combined/materialPackage/combined/d1_s1.png"
    });
    combos.append({
        "连衣裙套装2",
        "",           // top: 为空
        "蓝色连衣裙",  // dress: 连衣裙名称
        "",           // bottom: 为空
        "凉鞋",       // shoes: 鞋子名称
        ":/combined/materialPackage/combined/d2_s1.png"
    });
    combos.append({
        "连衣裙套装3",
        "",           // top: 为空
        "中式连衣裙",  // dress: 连衣裙名称
        "",           // bottom: 为空
        "皮鞋",       // shoes: 鞋子名称
        ":/combined/materialPackage/combined/d3_s2.png"
    });

    // 添加套装组合，根据实际资源路径修改
    combos.append({
        "运动套装",
        "蓝色T恤","","运动裤", "运动鞋",
        ":/combined/materialPackage/combined/T2_t1_s3.png"
    });

    // 添加套装组合，根据实际资源路径修改
    combos.append({
        "牛仔套装",
        "牛仔外套","","牛仔裤", "皮鞋",
        ":/combined/materialPackage/combined/ja_t2_s2.png"
    });
    // 添加套装组合，根据实际资源路径修改
    combos.append({
        "一身蓝套装",
        "蓝色T恤","","牛仔裤", "皮鞋",
        ":/combined/materialPackage/combined/T2_t2_s2.png"
    });
    // 添加套装组合，根据实际资源路径修改
    combos.append({
        "芬兰套装",
        "粉色T恤","","牛仔裤", "皮鞋",
        ":/combined/materialPackage/combined/T3_t2_s2.png"
    });
    // 添加套装组合，根据实际资源路径修改
    combos.append({
        "阳光套装",
        "黄色T恤","","运动裤", "凉鞋",
        ":/combined/materialPackage/combined/T4_t1_s1.png"
    });
    // 添加套装组合，根据实际资源路径修改
    combos.append({
        "阳光运动",
        "黄色T恤","","运动裤", "运动鞋",
        ":/combined/materialPackage/combined/T4_t1_s3.png"
    });

    return combos;
}

bool ResourceManager::checkAudioDevices()
{
    QAudioDeviceInfo defaultDevice = QAudioDeviceInfo::defaultOutputDevice();
    if (defaultDevice.isNull())
    {
        qWarning() << "无可用音频设备";
        return false;
    }
    return true;
}

QString ResourceManager::getDefaultBgmPath()
{
    return ":/bgm/materialPackage/bgm/happy.wav";
}

QString ResourceManager::getDefaultCharacterPath()
{
    // 根据实际人物图片路径修改
    return ":/girl/materialPackage/cartoolgirl.png";
}

QString ResourceManager::getScenePath(int sceneType)
{
    if (sceneType == 1)
    {
        return ":/scene/materialPackage/scene/roomscene.png";
    } else {
        return ":/scene/materialPackage/scene/schoolscene.png";
    }
}
